package com.lxq.live.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.core.env.EnvironmentCapable;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;

@Component
public class LiveMailService {

    @Autowired
    JavaMailSender javaMailSender;
    @Autowired
    Environment env;

    public void sendSimpleMail(String mailTitle,String sendTo,String mailText){
        var simpleMessage=new SimpleMailMessage();
        simpleMessage.setSubject(mailTitle);
        simpleMessage.setFrom(env.getProperty("spring.mail.username"));
        simpleMessage.setTo(sendTo);
        simpleMessage.setText(mailText);
        javaMailSender.send(simpleMessage);
    }
}
